package leetcode.sword;

import datastruct.tree.TreeNode;

public class Solution28 {

    public boolean isSymmetric(TreeNode root) {
        if(root==null) return true;
        return isSym(root.left,root.right);
    }

    public boolean isSym(TreeNode r1, TreeNode r2){
        if(r1==null&&r2==null) return true;
        if(r1!=null&&r2==null||r1==null&&r2!=null) return false;
        return r1.val==r2.val && isSym(r1.left,r2.right) && isSym(r1.right,r2.left);
    }

}
